#include "meshTypes.hpp"
#include "vtkFunctions.hpp"

namespace hms::vtk
{

template<typename Derived>
void matrixToText( xml::XMLElement* el, const Eigen::DenseBase<Derived>& matrix
){
	std::stringstream converter { getConverter() };
	write(converter, matrix);
	el->SetText( converter.str().c_str() );
};

template<typename T>
xml::XMLElement* findChildWithAttributeOrInsert(
	xml::XMLElement* parent,
	const char* childName,
	const char* attributeName,
	T&& attributeValue
){
	xml::XMLElement* child { internal::getChildNodeByAttributeValue(
		parent,
		childName,
		attributeName,
		attributeValue
	)};
	if (!child){
		child = parent->InsertNewChildElement(childName);
		child->SetAttribute(attributeName, attributeValue);
	}
	return child;
}


} // end namespace hms::vtk
